<?php
/**
 * Created by DRCOM.
 * User: GZX
 * Datetime: 2021-08-06 13:23
 */

namespace app\index\controller;


class Test
{
    public function index()
    {
        $content = '百雀羚小雀幸静润补水面膜20片
20点用88-5购 粅劵 
拍 芐29亓 饭5喵/超卡 实际24亓
￥hdbddR15Nol)/ AA00';
        $data = [
            'apkey'       => '6a9ffd88-17a3-9f54-0bb7-b91a81405862',
            'tbname'      => 'tb370655212',
            'pid'         => 'mm_1520060136_2232550319_111183800425',//常规
            'content'     => $content,
            'tpwd'        => 1,
            'hasiteminfo' => 1,
        ];

        $url = "http://api.web.ecapi.cn/taoke/doItemHighCommissionPromotionLinkByAll?";
        $params = http_build_query($data);
        $result = file_get_contents($url . $params);
        echo $result;

    }


    public function jd()
    {
        $startTime = '2021-12-13 22:00:00';
        $endTime = '2021-12-13 23:00:00';
        $orders = jd_order_details($startTime, $endTime);
        dump($orders);
    }

    public function cachetpwd()
    {
        $cache = cache('tpwd', null);


    }

    /*
     *             $data[] = [
                    'goods_id' => $goods['goods_id'],
                    'goods_name' => $goods['goods_name'],
                    'selling_point' => $goods['selling_point'],
                    'goods_image' => $goods['goods_images'][0]['preview_url'],
                    'goods_price_min' => $goods['goods_price_min'],
                    'goods_price_max' => $goods['goods_price_max'],
                    'line_price_min' => $goods['line_price_min'],
                    'line_price_max' => $goods['line_price_max'],
                    'goods_sales' => $goods['goods_sales'],
                ];
     */
    public function dy()
    {
        $url = 'http://v2.api.haodanku.com/get_current_commission?apikey=sylar&min_id=1&back=100';
        $contents = file_get_contents($url);
        $contents = json_decode($contents, true);
        foreach ($contents['data'] as $goods) {
            $data[] = [
                'goods_id'        => $goods['itemid'],
                'goods_name'      => $goods['itemtitle'],
                'selling_point'   => $goods['itemdesc'],
                'goods_image'     => $goods['itempic'],
                'goods_price_min' => $goods['itemendprice'],
                'goods_price_max' => $goods['itemendprice'],
                'line_price_min'  => $goods['itemprice'],
                'line_price_max'  => $goods['itemprice'],
                'goods_sales'     => $goods['itemsale'],
            ];
        }
    }

    public function detail(){
        $url = 'http://v2.api.haodanku.com/item_detail?apikey=sylar&itemid=672547535486';
        $contents = file_get_contents($url);
        $contents = json_decode($contents, true);
        $data = [];
        if (isset($contents['data'])){

            $info = $contents['data'];
            $tbimgs = explode(',',$info['taobao_image']);
            $imgs = [];
            foreach ($tbimgs as $k=>$v){
                $imgs[$k]['preview_url'] = $v;
            }
            $data['goods_image'] = $info['itempic'];
            $data['goods_images'] = $imgs;
            $data['goods_id'] = $info['itemid'];
            $data['goods_price_min'] = $info['itemendprice'];
            $data['line_price_min'] = $info['itemprice'];
            $data['goods_sales'] = $info['itemsale'];
            $data['goods_name'] = $info['itemtitle'];
            $data['selling_point'] = $info['itemdesc'];
            $data['content'] = $info;//此处后面修改
        }
        dump($data);
    }


//淘礼金创建
    function create_taolijin($itemid = 0, $money = 1, $num = 1)
    {
        $secret = 'c68903937449446f4c892a05f3892765';
        $data = [
            'apkey'           => '6a9ffd88-17a3-9f54-0bb7-b91a81405862',
            'tbname'          => 'tb370655212',
            'tbappkey'        => 32823552,
            'tbappsecret'     => $secret,//有淘礼金权限的Appkey，不知道有没有的登录：open.taobao.com，进行查看
            'adzoneid'        => '111186000312',//妈妈广告位Id，PID第三段
            'itemid'          => $itemid,
            'end_time'        => date('Y-m-d 23:59:59'),
            'start_time'      => date('Y-m-d H:i:s'),
            'num'             => $num,
            'name'            => '潘多拉的魔盒',
            'win_limit'       => 1,//	单用户累计中奖次数上限
            'secure'          => false,
            'money'           => $money,
            'security_switch' => 'false',
        ];
        $url = "http://api.web.ecapi.cn/taoke/create_taolijin?";
        $params = http_build_query($data);
        $result = file_get_contents($url . $params);
        $content = json_decode($result, true);
        return $content;
    }


    public function fuck($adzoneId = '111186000312', $num = 1, $text = '一个好的东西')
    {

        vendor("taobao.TopSdk");
        $c = new \TopClient;
        $c->appkey = '32823552';
        $c->secretKey = 'c68903937449446f4c892a05f3892765';
        $c->format = 'json';

        $req = new \TbkDgVegasTljReportRequest;
        $req->setRightsId("EwUWH%2FT7Hi4Bn1JdKA0pyG38LIQOFtFt");
        $req->setAdzoneId("111186000312");
        $resp = $c->execute($req);
        dump($resp);

    }

    public function ele(){

        $data = [
            'apkey'       => '6a9ffd88-17a3-9f54-0bb7-b91a81405862',
            'activity_id'      => '10144',
            's_id' => '1306',


        ];
        $url = "http://api.web.ecapi.cn/alsc/getTbkActivityInfo?";

        $params = http_build_query($data);
        $result = file_get_contents($url . $params);
        $content = json_decode($result, true);
        dump($content) ;
    }

}